<!--头部公共部分-->
{include file="common/header" /}
<div style="padding: 15px;">
	<form class="layui-form layui-form-pane">
		<div class="layui-tab">
			<ul class="layui-tab-title">
				<li class="layui-this">平台设置</li>
				<li>关于我们</li>
				<li>权限分配</li>
				<li>商品管理</li>
				<li>订单管理</li>
			</ul>
			<div class="layui-tab-content">
				<div class="layui-tab-item layui-show" style="margin: 25px;">
					<div class="layui-form-item">
						<label class="layui-form-label">{$platform_settings['platform_title']['name']}：</label>
						<div class="layui-input-inline" style="width: 350px;">
							<input type="text" name="platform_title" value="{$platform_settings['platform_title']['value']}" autocomplete="off" placeholder="请输入平台名称" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item layui-form-text" style="width: 460px;">
						<label class="layui-form-label">{$platform_settings['platform_desc']['name']}：</label>
						<div class="layui-input-block">
							<textarea placeholder="请输入平台描述" name="platform_desc" class="layui-textarea">{$platform_settings['platform_desc']['value']}</textarea>
						</div>
					</div>
					<div class="layui-upload">
						<label class="layui-form-label">{$platform_settings['platform_logo']['name']}：</label>
						<input type="hidden" name="platform_logo" value="{$platform_settings['platform_logo']['value']}">
						<button type="button" class="layui-btn layui-btn-danger" id="platform_logo">上传图片</button>
						<div class="layui-upload-list">
							<img class="layui-upload-img" id="thumb_img" style="width: 90px;height: 90px;margin-left: 110px;" src="{$platform_settings['platform_logo']['value']}">
							<p id="demoText"></p>
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">{$platform_settings['company']['name']}：</label>
						<div class="layui-input-inline" style="width: 350px;">
							<input type="text" name="company" value="{$platform_settings['company']['value']}" autocomplete="off" placeholder="请输入公司名称" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">{$platform_settings['company_address']['name']}：</label>
						<div class="layui-input-inline" style="width: 350px;">
							<input type="text" name="company_address" value="{$platform_settings['company_address']['value']}" autocomplete="off" placeholder="请输入公司地址" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">{$platform_settings['email']['name']}：</label>
						<div class="layui-input-inline" style="width: 350px;">
							<input type="text" name="email" value="{$platform_settings['email']['value']}" autocomplete="off" placeholder="请输入邮箱地址" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">{$platform_settings['landline']['name']}：</label>
						<div class="layui-input-inline" style="width: 350px;">
							<input type="text" name="landline" value="{$platform_settings['landline']['value']}" autocomplete="off" placeholder="请输入座机号码" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">{$platform_settings['record_information']['name']}：</label>
						<div class="layui-input-inline" style="width: 350px;">
							<input type="text" name="record_information" value="{$platform_settings['record_information']['value']}" autocomplete="off" placeholder="请输入备案信息" class="layui-input">
						</div>
						<div class="layui-form-mid layui-word-aux">如：京ICP备19000000号-1</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">{$platform_settings['distribution_type']['name']}：</label>
						<div class="layui-input-inline"  style="width: 350px;">
							<input type="radio" lay-filter="distribution_type" name="distribution_type" value="1" title="指定分配" {eq name="$platform_settings['distribution_type']['value']" value="1" }checked{/eq}>
							<input type="radio" lay-filter="distribution_type" name="distribution_type" value="2" title="对应分配" {eq name="$platform_settings['distribution_type']['value']" value="2" }checked{/eq}>
						</div>
					</div>

				</div>
				<div class="layui-tab-item">
					<div class="layui-form-item layui-form-text"  style="width: 460px;">
						<label class="layui-form-label">{$platform_settings['content']['name']}：</label>
						<div class="layui-input-block">
							<textarea placeholder="请输入内容" name="content" class="layui-textarea">{$platform_settings['content']['value']}</textarea>
						</div>
					</div>

					<div class="layui-form-item layui-form-text"  style="width: 460px;">
						<label class="layui-form-label">{$platform_settings['sketch']['name']}：</label>
						<div class="layui-input-block">
							<textarea placeholder="请输入内容" name="sketch" class="layui-textarea">{$platform_settings['sketch']['value']}</textarea>
						</div>
					</div>
				</div>
				<div class="layui-tab-item">内容3</div>
				<div class="layui-tab-item">内容4</div>
				<div class="layui-tab-item">内容5</div>
			</div>
		</div>

		<div class="layui-form-item">
			<div class="layui-input-block">
				<input class="layui-btn" lay-submit lay-filter="form" value="保存" readonly>
			</div>
		</div>
	</form>
</div>
<!--底部公共部分-->
{include file="common/footer" /}

<script>
	layui.use(['element', 'jquery','upload','form','layer'], function(){
		var $ = layui.jquery
			,element = layui.element
			,layer = layui.layer
			,upload = layui.upload
			,form = layui.form;

		//图片上传
		upload.render({
			elem: '#platform_logo',
			url: '{:url("System/upload_logo")}',
			before: function(obj) {
				//预读本地文件示例，不支持ie8
				obj.preview(function(index, file, result) {
					$('#thumb_img').attr('src', result); //图片链接（base64）
				});
			},
			done: function(res) {
				//如果上传失败
				if(res.code > 0) {
					return layer.msg('上传失败');
				}
				//上传成功
				layer.msg('上传成功');
				$('input[name=platform_logo]').val(res.data);
			}
		});

		//监听提交
		form.on('submit(form)', function (data) {
			let field = data.field;
			let isLoad;
			$.ajax({
				url: '{:url("System/setting")}',
				method: "post",
				data: field,
				beforeSend: function () {
					isLoad = layer.load(0, {
						shade: false
					}); //0代表加载的风格，支持0-2
				},
				success: function (result) {
					layer.msg(result.msg);
					if (result.status == true) {
						setTimeout(function () {
							location.reload();
						}, 2000);
					}
				},
				complete: function () {
					layer.close(isLoad)
				},
				error: function (error) {
					console.log(error)
				}
			});
			return false;
		});
	});
</script>